OpenCV QRCodeDetector内存不足,即使有一个小文件

您所在的位置:网站首页 opencv cnn OpenCV QRCodeDetector内存不足,即使有一个小文件

OpenCV QRCodeDetector内存不足,即使有一个小文件

2023-04-03 11:11| 来源: 网络整理| 查看: 265

简短回答:

试试WeChatQRCode

长答案:

使用QRCodeDetector解码存在几个开放内存问题。我希望在未来的版本中,它将是固定的。同时,您也可以尝试使用WeChatQRCode (也来自cv2 )。

WeChatQRCode包括两个基于CNN的模型:一个目标检测模型和一个超级分辨率模型.采用对象检测模型对QRCode进行边界盒检测。当QRCode很小时,采用超分辨率模型进行缩放。

修改了您的代码:

import cv2 # Name of the QR Code Image file filename = "2021-12-14_162414.png" # read the QRCODE image image = cv2.imread(filename) # initialize the cv2 QRCode detector detector =cv2.wechat_qrcode_WeChatQRCode(detector_prototxt_path = "detect.prototxt", detector_caffe_model_path = "detect.caffemodel", super_resolution_prototxt_path = "sr.prototxt", super_resolution_caffe_model_path = "sr.caffemodel") # detect and decode data, vertices_array = detector.detectAndDecode(image) # if there is a QR code # print the data if vertices_array is not None: print("QRCode data:") print(data) else: print("There was some error")

输出:

QRCode data: ('PK\x03\x04\n',)

如您所见,它需要原型文件和caffemodel文件。你可以找到他们here。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3